
ROOT_PATH := ../..

include $(ROOT_PATH)/build/makefile.inc

OUTPUT_PATH := $(ROOT_PATH)/target/obj

LIBPATH += -L $(ROOT_PATH)/target/obj/system/lib
LDFLAGS += -lpthread -lxml2 -lrt  -lipc_evt_api  -lelog -lsys

TARGET := interprocess

INCDIR := ./inc
SRCDIR := ./src
OBJDIR := $(OUTPUT_PATH)/package/obj/interprocess
LIBDIR := $(OUTPUT_PATH)/package/lib
BINDIR := $(OUTPUT_PATH)/package/bin

INCS := -I$(INCDIR)
INCS += -I$(ROOT_PATH)/system/elog/inc
INCS += -I$(ROOT_PATH)/system/common/h
LIBS :=

FLAGS := $(CFLAGS)

SOURCES := $(patsubst %.cpp,%.cpp,$(notdir $(wildcard $(SRCDIR)/*.cpp)))
OBJECTS := $(addprefix $(OBJDIR)/, $(SOURCES:.cpp=.o))

$(BINDIR)/$(TARGET): $(OBJECTS)
	@mkdir -p $(OBJDIR) $(LIBDIR) $(BINDIR)
	@$(CXX) -o $@ $(FLAGS) $(OBJECTS) $(LIBS) ${LIBPATH} $(LDFLAGS)
	@echo -e "\033[1;32;40m [SUCCESS] \033[0m\033[1;40m build   $(notdir $@)\033[0m"

$(OBJECTS): $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
	@mkdir -p $(OBJDIR)
	@$(CXX) -c $(FLAGS) -fpie $(INCS) -o $@ $<

all: $(OBJECTS) $(BINDIR)/$(TARGET)

clean:
	rm -f $(OBJECTS) $(BINDIR)/$(TARGET)

.PHONY: all clean
